import Vue from 'vue'
import Router from 'vue-router'
import Home from "../components/Home";
import Note from "../components/Note";
import Moments from "../components/Moments";
import Chat from "../components/Chat";
import BlogDetail from "../components/BlogDetail";
import AddBlog from "../components/AddBlog";
import Editor from "../components/Editor";
import About from "../components/About";

Vue.use(Router);

/*重复点击子路由报错，添加这段代码*/
let VueRouterPush = Router.prototype.push;
Router.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
};

export default new Router({
  routes: [
    {
      path: '/home',
      name: 'Home',
      component: Home,
      children: [
        {name: 'Note', path:'/note', component:Note},
        {name: 'Moments', path:'/moments', component:Moments},
        {name: 'Chat', path:'/chat', component:Chat},
        {name: 'About', path:'/about', component:About},
      ]
    },
    {
      path: '/blogDetail',
      name: 'BlogDetail',
      component: BlogDetail,
    },
    {
      path: '/addBlog',
      name: 'AddBlog',
      component: AddBlog,
    },
    {
      path: '/editor',
      name: 'Editor',
      component: Editor,
    }
  ]
})
